package cn.sieis.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.sieis.pojo.Student;
import cn.sieis.service.student.StudentService;

@Controller
public class RegisterFrontController {

	@Autowired
	private StudentService studentService;

	@RequestMapping(value = "/front/register.html", method = RequestMethod.GET)
	public String register(@ModelAttribute("student") Student student) throws Exception {
		return "front/register";
	}

	@RequestMapping(value = "/front/saveregister.html", method = RequestMethod.POST)
	public String doRegister(Student student, HttpSession session, HttpServletRequest request) throws Exception {
		boolean flag = true;
		if (flag) {
			try {
				if (studentService.register(student)) {
					return "/front/index";
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return "front/register";

	}

}
